package com.syj.jsxjj.ui.my.presenter;

import com.syj.jsxjj.base.BasePresenter;
import com.syj.jsxjj.http.HttpManager;
import com.syj.jsxjj.http.HttpSubscriber;
import com.syj.jsxjj.ui.my.bean.CouponBean;
import com.syj.jsxjj.ui.my.contract.CouponContract;

/**
 * Created by gyl on 2017/5/12 0012.
 */

public class CouponPresenter extends BasePresenter<CouponContract.View> implements CouponContract.Presenter {
    @Override
    public void Coupon(String status, String pageNum) {
        toSubscribe(HttpManager.getApi().getUserCoupon(status, pageNum), new HttpSubscriber<CouponBean>() {
            @Override
            protected void _onStart() {
                mView.showLoading("");
            }

            @Override
            protected void _onNext(CouponBean couponBean) {
                if (couponBean.getItem() != null) {
                    mView.CouponSuccess(couponBean.getItem());
                } else {
                    mView.showErrorMsg("数据获取失败，请重新获取", null);
                }
            }

            @Override
            protected void _onError(String message) {
                mView.showErrorMsg(message, null);
            }

            @Override
            protected void _onCompleted() {
                mView.stopLoading();
            }
        });
    }
}
